<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>接龙游戏</title>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/base.css" />
		<link rel="stylesheet" type="text/css" href="css/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="css/mineClearance.css" />
		<script src="js/jquery-3.1.1.js"></script>
		<script src="js/flexible.js"></script>
		<script src="js/mui.min.js"></script>
		<script src="js/iconfont.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/template.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/confi.js"></script>
	</head>
	<body>
		<header class="mui-bar mui-bar-nav">
			<a href="index.html" class="mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">接龙游戏</h1>
		</header>
		<ul id="mine" class="mine">
			<!--<li>
				<div>【新手区一】 </div>
				<div class="money">
					10元5包
				</div> 
			</li>-->
		</ul>
		<script type="text/template" id="mimeList">
			{{each items as value index}}
			<li>
				<div id="{{value.room_id}}" class="solitaireName">【{{value.room_name}}】</div>
				<div id="{{value.type}}" class="money">
					<span class="solitairegold">{{value.gold_range}}</span>
				</div>
			</li>
			{{/each}}
		</script>

		<script type="text/javascript">
			var token = localStorage.getItem('token');
			mui.ajax(config.host + "/home/Index/roomList", {
				headers: {
					'token': token
				},
				dataType: 'json', //服务器返回json格式数据
				type: 'post', //HTTP请求类型	
				data: {
					roomT: 2
				},
				success: function(data) {
					if(data.code == 200) {
						if(data.data.length != 0) {
							var mineHtml = template('mimeList', {
								"items": data.data.roomList
							});
							$('#mine').html(mineHtml);
						} else {
							$('#shouruCon').html('暂无数据');
							$('#shouruCon').css({
								'height': '50px',
								'line-height': '50px',
								"text-align": 'center'
							});
						}
					} else {
						mui.toast("数据获取失败");
					}
				}
			})
			//接龙
			$("#mine").on('tap','li', function() {
				 var _index=$(this).index();
				 var roomId=$('.solitaireName').eq(_index).attr('id');
				 var roomType=$('.money').eq(_index).attr('id');
				 var roomBao=$('.solitairegold').eq(_index).text();
				 var bi=roomBao.indexOf('币');
				 var bao=roomBao.indexOf('包');
				 var biNum=roomBao.substring(0,bi);
				 var baoNum=roomBao.substring(bi+1,bao);
				 location.href="xihongshihongbao.html?roomId="+roomId+"=roomtype="+roomType+"=biNum="+biNum+"=baoNum="+baoNum;
			})
		</script>
	</body>
</html>
